I currently have this in the button's client-side onclick event:
var reqReason='#{javascript: wfRequireRejReason(compositeData.documentData)}';
if (!reqReason) return true;
dijit.byId('wfRejectionDialogue').show();
return false;
And this in its server-side onclick event (set to full update):
wfRunAction(compositeData.documentData,'WorkflowRejectNoteId',wfaTypeReject);
wfRunAction is a function in a SSJS library, and wfaTypeReject is a global variable (effectively a constant) in the same library.
Note that the client-side event includes some in-line SSJS. This is the part currently running on page load/refresh which I want to run when the button is clicked.
So... what I really want is one button click that does all this in sequence:
- Run SSJS with a full update to modify client-side JS.
- Run the modified client-side JS.
- If the client-side JS returns true, run SSJS with a full update.
I think I want a full update on the first piece of SSJS, because it needs to get all field values currently displayed, though I don't want data sources saved at that point.
I've just tried changing the client-side script to the following alternative, but it doesn't work. It seems that XSP.partialRefreshPost returns immediately (i.e. is asynchronous) and the SSJS onclick event runs without waiting for the important part of the client-side JS to finish.
XSP.partialRefreshPost('#{id:divRequireRejReason}',{
onComplete: function() {
alert('partialRefreshPost finished');
if (!wfReqReason) return true;
dijit.byId('wfRejectionDialogue').show();
return false;
}
});
Regardless of whether I get this working, your first reply is useful just because I didn't know that "onComplete" and "XSP.partialRefreshPost" existed.